//
// CLodCharacterShape.java
// Copyright (C) 2010  "Naush" <naush _ hotmail _ fr>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program.  If not, see <http://www.gnu.org/licenses/>./* ----------------------------------------------------------------------------







package org.ryzom.nel.threed;

import org.ryzom.nel.misc.CUV;
import org.ryzom.nel.misc.CVector;
import org.ryzom.nel.misc.IStream;

public class CLodCharacterShape {
  private long swigCPtr;
  protected boolean swigCMemOwn;

  public CLodCharacterShape(long cPtr, boolean cMemoryOwn) {
    swigCMemOwn = cMemoryOwn;
    swigCPtr = cPtr;
  }

  public static long getCPtr(CLodCharacterShape obj) {
    return (obj == null) ? 0 : obj.swigCPtr;
  }

  protected void finalize() {
    delete();
  }

  public synchronized void delete() {
    if (swigCPtr != 0) {
      if (swigCMemOwn) {
        swigCMemOwn = false;
        nel3dJNI.delete_CLodCharacterShape(swigCPtr);
      }
      swigCPtr = 0;
    }
  }

  public CLodCharacterShape() {
    this(nel3dJNI.new_CLodCharacterShape(), true);
  }

  public void buildMesh(String name, CLodCharacterShapeBuild lodBuild) {
    nel3dJNI.CLodCharacterShape_buildMesh(swigCPtr, this, name, CLodCharacterShapeBuild.getCPtr(lodBuild), lodBuild);
  }

  public boolean addAnim(SWIGTYPE_p_NL3D__CLodCharacterShape__CAnimBuild animBuild) {
    return nel3dJNI.CLodCharacterShape_addAnim(swigCPtr, this, SWIGTYPE_p_NL3D__CLodCharacterShape__CAnimBuild.getCPtr(animBuild));
  }

  public void serial(IStream f) {
    nel3dJNI.CLodCharacterShape_serial(swigCPtr, this, IStream.getCPtr(f), f);
  }

  public String getName() {
    return nel3dJNI.CLodCharacterShape_getName(swigCPtr, this);
  }

  public int getAnimIdByName(String name) {
    return nel3dJNI.CLodCharacterShape_getAnimIdByName(swigCPtr, this, name);
  }

  public long getNumVertices() {
    return nel3dJNI.CLodCharacterShape_getNumVertices(swigCPtr, this);
  }

  public long getNumTriangles() {
    return nel3dJNI.CLodCharacterShape_getNumTriangles(swigCPtr, this);
  }

  public long getNumBones() {
    return nel3dJNI.CLodCharacterShape_getNumBones(swigCPtr, this);
  }

  public int getBoneIdByName(String name) {
    return nel3dJNI.CLodCharacterShape_getBoneIdByName(swigCPtr, this, name);
  }

  public SWIGTYPE_p_unsigned_int getTriangleArray() {
    long cPtr = nel3dJNI.CLodCharacterShape_getTriangleArray(swigCPtr, this);
    return (cPtr == 0) ? null : new SWIGTYPE_p_unsigned_int(cPtr, false);
  }

  public Vector_uint16 getTriangleIndices() {
    return new Vector_uint16(nel3dJNI.CLodCharacterShape_getTriangleIndices(swigCPtr, this), false);
  }

  public CUV getUVs() {
    long cPtr = nel3dJNI.CLodCharacterShape_getUVs(swigCPtr, this);
    return (cPtr == 0) ? null : new CUV(cPtr, false);
  }

  public CVector getNormals() {
    long cPtr = nel3dJNI.CLodCharacterShape_getNormals(swigCPtr, this);
    return (cPtr == 0) ? null : new CVector(cPtr, false);
  }

  public void startBoneAlpha(SWIGTYPE_p_std__vectorT_unsigned_char_t tmpAlphas) {
    nel3dJNI.CLodCharacterShape_startBoneAlpha(swigCPtr, this, SWIGTYPE_p_std__vectorT_unsigned_char_t.getCPtr(tmpAlphas));
  }

  public void addBoneAlpha(long boneId, SWIGTYPE_p_std__vectorT_unsigned_char_t tmpAlphas) {
    nel3dJNI.CLodCharacterShape_addBoneAlpha(swigCPtr, this, boneId, SWIGTYPE_p_std__vectorT_unsigned_char_t.getCPtr(tmpAlphas));
  }

  public SWIGTYPE_p_NL3D__CLodCharacterShape__CVector3s getAnimKey(long animId, double time, boolean wrapMode, CVector unPackScaleFactor) {
    long cPtr = nel3dJNI.CLodCharacterShape_getAnimKey(swigCPtr, this, animId, time, wrapMode, CVector.getCPtr(unPackScaleFactor), unPackScaleFactor);
    return (cPtr == 0) ? null : new SWIGTYPE_p_NL3D__CLodCharacterShape__CVector3s(cPtr, false);
  }

}
